using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication4
{
    public partial class loading : Form
    {
        public loading()
        {
            InitializeComponent();
            this.DialogResult = DialogResult.OK;
        }

        //Overload Show method, hides inherited Show method
        new public void Show()
        {
            //Show loading form as a dialog
            loading loadForm = new loading();
            //Will not return until closed
            loadForm.ShowDialog();
        }

        //Overload Show method, hides inherited Show method
        public void Show(string loadingText, string loadingCaption)
        {            
            //Show loading form as a dialog
            loading loadForm = new loading();
            loadForm.LoadingTextLabel.Text = loadingText;
            loadForm.Text = loadingCaption;

            //Will not return until closed
            loadForm.ShowDialog();
        }

        private void loading_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Don't let user close form
            if (this.DialogResult == DialogResult.Cancel)
            {
                e.Cancel = true;
            }
        }

        private void loading_VisibleChanged(object sender, EventArgs e)
        {
            //Try to keep user from closing form
            //Doesn't work for some reason
            if (this.DialogResult == DialogResult.Cancel)
            {
                this.Visible = true;
            }
        }
    }
}